@echo off
chcp 65001
setlocal enabledelayedexpansion

set buildType=%1
set hour=%time:~0,2%
if "%hour:~0,1%" == " " set hour=0%hour:~1,1%

set substring=%date:~3,4%-%date:~8,2%-%date:~11,2%-%hour%-%time:~3,2%-%time:~6,2%
set aarFileName=unityLibrary_%substring%.aar

if "%buildType%"=="DEBUG" (
	
	C:\mateurp_pipline\obsutil\obsutil cp C:\mateurp_pipline\mateurp\mateurp\Build\Android\DEBUG\MateAi\unityLibrary\build\outputs\aar\unityLibrary-debug.aar obs://wlops/mateurp_android/%buildType%/%aarFileName%
)

if "%buildType%"=="RELEASE" (
	
	C:\mateurp_pipline\obsutil\obsutil cp C:\mateurp_pipline\mateurp\mateurp\Build\Android\RELEASE\MateAi\unityLibrary\build\outputs\aar\unityLibrary-release.aar obs://wlops/mateurp_android/%buildType%/%aarFileName%
)

set buildDir=C:\mateurp_pipline\mateurp\mateurp\Build\Android\%buildType%\MateAi\unityLibrary
set symbolFileName=symbols_%substring%.zip
"C:\Program Files\7-Zip\7z.exe" a -r "%buildDir%\symbols.zip" "%buildDir%\symbols\*"
C:\mateurp_pipline\obsutil\obsutil cp "%buildDir%\symbols.zip" obs://wlops/mateurp_android/%buildType%/%symbolFileName%

set downloadUrl=https://wlops.obs.cn-north-4.myhuaweicloud.com/mateurp_android/%buildType%/%aarFileName%
echo downloadUrl: %downloadUrl%
echo %aarFileName% upload finish

set symbleUrl=https://wlops.obs.cn-north-4.myhuaweicloud.com/mateurp_android/%buildType%/%symbolFileName%
echo symbleUrl: %symbleUrl%

set json="{\"text\":{\"content\":\"安卓AAR打包完成,下载地址 %downloadUrl% 符号地址:%symbleUrl% \" },\"msgtype\":\"text\"}"
echo %json%
curl --ssl-no-revoke -H "Content-Type: application/json" -X POST -d !json! https://oapi.dingtalk.com/robot/send?access_token=1dd9ef311951334ba9e001f194f78c99ee8b74fff2c56b5f899c1727302f60b8

endlocal
